package btp.Calendars;

public class EthiopicCalendar {
	//	The Ethiopic calendar is identical to the Coptic calendar except for the epoch, the month and day names.

	//Epoch at 29, August 284 CE(Julian) at 1 AM.
		public static final long EPOCH = JulianCalendar.getRDFromJulian(8, JulianCalendar.AUGUST, 29);
		
		//Months
		public static final int MASKARAM = 1;
		public static final int TEQEMT = 2;
		public static final int HADAR = 3;
		public static final int TAKHSAS = 4;
		public static final int TER = 5;
		public static final int YAKATIT = 6;
		public static final int MAGABIT = 7;
		public static final int MIYAZYA = 8;
		public static final int GENBOT = 9;
		public static final int SANE = 10;
		public static final int HAMLE = 11;
		public static final int NAHASE = 12;
		public static final int PAGUEMEN = 13;
		
//		Days
		public static final int IHUD = 0;
		public static final int SANYO = 1;
		public static final int MAKSANYO = 2;
		public static final int ROBUE = 3;
		public static final int HAMUS = 4;
		public static final int ARB = 5;
		public static final int KIDAMME = 6;

		int year;
		int month;
		int day;
		

		public int getDayOfWeek(){
			return RataDie.dayOfWeek(getRDFromCalendar());
		}
		
		public String getStringForDay(){
			switch(getDayOfWeek()){
			case 0: return "Ihud";
			case 1: return "Sanyo";
			case 2: return "Maksanyo";
			case 3: return "Robue";
			case 4: return "Hamus";
			case 5: return "Arb";
			case 6: return "Kidamme";
			}
			return null;
		}
		
		public static boolean isYearLeap(int year){
			return (year%4<0)?(year%4==-1):(year%4==3);
		}
		
		public boolean isYearLeap(){
			return isYearLeap(year);
		}
		
		public long getRDFromCalendar() {
			return (long) (EPOCH + 365*(year-1) + 30*(month-1) + day-1 + Math.floor(year/4.0));
		}

		
		public static EthiopicCalendar getCalendarFromRD(long rd){
			CopticCalendar c = CopticCalendar.getCalendarFromRD(rd+CopticCalendar.EPOCH-EPOCH); 
			return new EthiopicCalendar(c.year, c.month, c.day);
		}

		public EthiopicCalendar(int year, int month, int day) {
			this.year = year;
			this.month = month;
			this.day = day;
		}
		


}

